<?php

namespace App\Models;


class Qtag extends Base
{
      // 转换数组为字符串
      public function setFullNameAttribute($value){
        $this->attributes['full_name'] = is_array($value) && count($value) ? implode(',', $value) : '';
    }

    // 转换字符串为数组
    public function getFullNameAttribute($value){
        return $value ? explode(',', $value) : [];
    }

    /**
     * 视频（多对多关系）
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function questions() {
        return $this->belongsToMany(Question::class, 'question_qtags')->using(QuestionQtag::class);
    }
}
